import Vue from 'vue'
import Vuex from 'vuex'
// 导入购物车的 vuex 模块
import moduleCart from './cart.js'
import moduleUser from './address.js'

Vue.use(Vuex)

const store = new Vuex.Store({
	modules:{
		m_cart: moduleCart,
		m_user:moduleUser
	},
	state:{
		tabbar: [{	
				pagePath: "/pages/home/home",
				text: "首页",
				iconPath: "/static/icon/home.png",
				selectedIconPath: "/static/icon/home-active.png"
			},
			{
				"pagePath": "/pages/cate/cate",
				"text": "分类",
				"iconPath": "/static/icon/cate.png",
				"selectedIconPath": "/static/icon/cate-active.png"
			},
			{
				"pagePath": "/pages/cart/cart",
				"text": "购物车",
				"iconPath": "/static/icon/cart.png",
				"selectedIconPath": "/static/icon/cart-active.png"
			},
			{
				"pagePath": "/pages/my/my",
				"text": "我的",
				"iconPath": "/static/icon/my.png",
				"selectedIconPath": "/static/icon/my-active.png"
			}
		],
		stateBarHeight: 0, //状态栏的高度
		tabBarHeight: 50, //标签栏的高度
		searchHearch: 30, //获取小程序纽扣高度
		windowWidth: 0, //手机窗口的宽度
	},
	mutations:{
		adaptive(state){
			let info = uni.getSystemInfoSync()
			state.stateBarHeight = info.statusBarHeight
			state.windowWidth = info.windowWidth
			
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			
			let paddingSize = menuButtonInfo.top - state.stateBarHeight
			state.searchHearch = menuButtonInfo.height
						
									 
			state.tabBarHeight = (menuButtonInfo.bottom- state.stateBarHeight) + paddingSize
								 
			state.windowWidth = menuButtonInfo.left
		}
	}
	
})

export default store	